#include<iostream>
#include<string>
using namespace std;
const int N=110;
string s[N];
int n;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>s[i];
	}
	bool f1=0,f2=0;
	for(int i=1;i<=n-1;i++){
		//检查长度
		if(s[i].length()>s[i+1].length())  f1=1;
		//检查字典序
		int idx=0;
		while(1){
			int a=s[i][idx]-'a'+1;
			int b=s[i+1][idx]-'a'+1;
			if(a>b){
				f2=1;
				break;
			}
			else if(a==b)idx++;
			else break;
			if(idx==s[i].length()+1)break;
		}
	}
	if(!f2&&f1)cout<<"lexicographically"<<endl;
	else if(f2&&!f1)cout<<"lengths"<<endl;
	else if(!f1&&!f2)cout<<"both"<<endl;
	else cout<<"none"<<endl;
	return 0;
}
